<?php


class NewBugForm extends BaseFormDoctrine
{
    public function setup()
	{
		$this->setWidgets(array(
			'id'           => new sfWidgetFormInputHidden(),
			'summary'      => new sfWidgetFormInput(),
			'description'  => new sfWidgetFormTextarea(),
			'type_id'      => new sfWidgetFormDoctrineSelect(array('model' => 'BugType')),
			'milestone_id' => new sfWidgetFormDoctrineSelect(array('model' => 'BugMilestone', 'add_empty' => 'None')),
			'project_id'   => new sfWidgetFormInputHidden(),
			'creator_id'   => new sfWidgetFormInputHidden(),
			'owner_id'     => new sfWidgetFormDoctrineSelect(array('model' => 'User', 'add_empty' => 'Unassigned')),
			'due_date'     => new sfWidgetFormRichDate(),
			'priority_id'  => new sfWidgetFormDoctrineSelect(array('model' => 'BugPriority')),
			'status_id'    => new sfWidgetFormDoctrineSelect(array('model' => 'BugStatus')),
			'comment'	   => new sfWidgetFormTextarea()
		));

		$this->setValidators(array(
			'id'           => new sfValidatorDoctrineChoice(array('model' => 'Bug', 'column' => 'id', 'required' => false)),
			'summary'      => new sfValidatorString(array('max_length' => 255)),
			'description'  => new sfValidatorString(array('min_length' => 20)),
			'type_id'      => new sfValidatorDoctrineChoice(array('model' => 'BugType')),
			'milestone_id' => new sfValidatorDoctrineChoice(array('model' => 'BugMilestone', 'required' => false)),
			'project_id'   => new sfValidatorDoctrineChoice(array('model' => 'Project')),
      		'creator_id'   => new sfValidatorDoctrineChoice(array('model' => 'User')),
			'owner_id'     => new sfValidatorDoctrineChoice(array('model' => 'User', 'required' => false)),
			'due_date'     => new sfValidatorDate(array('required' => false)),
			'priority_id'  => new sfValidatorDoctrineChoice(array('model' => 'BugPriority')),
			'status_id'    => new sfValidatorDoctrineChoice(array('model' => 'BugStatus')),
			'comment'	   => new sfValidatorString(array('required' => false))
		));
		
		$this->widgetSchema->setLabels(array(
			'type_id'    	=> 'Type',
			'milestone_id'	=> 'Milestone',
			'owner_id'		=> 'Assign to',
			'priority_id'	=> 'Priority',
			'status_id'		=> 'Status',
			'comment'		=> 'Comment'
		));

		$this->widgetSchema->setNameFormat('bug[%s]');
		
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
		
		unset($this['groups_list']);
		
		parent::setup();
	}

    public function getModelName()
    {
        return 'Bug';
    }
}

?>
